var area_id;
function load_good(areaid) {
	area_id = areaid;
	$("#catid_1").attr("value",areaid);
	var query = {"areaid":area_id};
	$.ajax( {
		type : "POST",
		url : "/admin.php/Index/ajaxgood",
		data : query,
		success : function(responce) {
			$("#load_good_1 #good").remove();
			$("#load_good_1").append(responce);
		},
		error : function(XMLResponse) {
		}
	});
}


function load_city(areaid) {
	area_id = areaid;
	$("#catid_1").attr("value",areaid);
	var query = {"areaid":area_id};
	$.ajax( {
		type : "POST",
		url : "/admin.php/Public/ajaxcity",
		data : query,
		success : function(responce) {
			$("#load_city_1 #city").remove();
			$("#load_city_1").append(responce);
		},
		error : function(XMLResponse) {
		}
	});
}


function load_catid(catid){
	$("#catid_1").attr("value",catid);
}

function addcate(m) {
	var v = $('#catid_1').attr("value");
	var l = $('#cates option').length;
	if(l >= m) {alert("超出最大行业数值"); return;}
	for(var i = 0; i < l; i++) {if($('#cates option').eq(i).attr('value') == v) {alert("该专长已经添加"); return;}}
	var e = $("#load_good_1 select option:selected"); 
	var c = s = '';
	for(var i = 0; i < e.length; i++) {
		if($("#load_good_1 select option:selected").eq(i).attr("value")) {
			s = $("#load_good_1 select option:selected").eq(i).text(); c += s + '/'; s = '';
		}
	}
	if(c) {
		c = c.replace('&amp;', '&'); c = c.substring(0, c.length-1); 
		addop('cates', v, c); 
		
		$('#catid').attr("value",$('#catid').attr("value") ? $('#catid').attr("value")+v+',' : ','+v+',');
	} else {
		alert("请选择专长");
	}
}
function addop(id, v, t) {
	var op = "<option value='"+v+"'>"+t+"</option>"; $('#cates').append(op);
}


function delcate() {
	if($("#cates option:selected").text()=="") {
		alert("请选择要删除的专长"); 
		$('#cates').focus();
		return;
	}else{
		var val = $('#catid').attr("value").replace(','+$("#cates option:selected").attr("value")+',', ',')
		$('#catid').attr("value",val);
		$('#cates option:selected').remove();
	}
}

function addcity(m) {
	var v = $('#catid_1').attr("value");
	//alert(v);
	var l = $('#cates option').length;
	//alert(l);
	if(l >= m) {alert("超出最大城市数量"); return;}
	for(var i = 0; i < l; i++) {if($('#cates option').eq(i).attr('value') == v) {alert("该城市已经添加"); return;}}
	var e = $("#load_city_1 select option:selected"); 
	var c = s = '';
	for(var i = 0; i < e.length; i++) {
		if($("#load_city_1 select option:selected").eq(i).attr("value")) {
			s = $("#load_city_1 select option:selected").eq(i).text(); c += s + '/'; s = '';
		}
	}
	if(c) {
		c = c.replace('&amp;', '&'); c = c.substring(0, c.length-1); 
	//	alert(c);
		addop('cates', v, c); 
		
		$('#catid').attr("value",$('#catid').attr("value") ? $('#catid').attr("value")+v+',' : ','+v+',');
	} else {
		alert("请选择城市");
	}
}

function delcity() {
	//alert($("#cates option[selected]").text());
	if($("#cates option:selected").text()=="") {
		alert("请选择要删除的城市"); 
		$('#cates').focus();
		return;
	}else{
		var val = $('#catid').attr("value").replace(','+$("#cates option:selected").attr("value")+',', ',')
		$('#catid').attr("value",val);
		$('#cates option:selected').remove();
	}
}



















